﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Collections;

namespace GA.Server.Configuration
{
    public class ServerPropertiesElementCollection : ConfigurationElementCollection
    {
        public ServerPropertyElement Get(string name)
        {
            return (ServerPropertyElement)BaseGet(name);
        }

        public void AddProperty(ServerPropertyElement property)
        {
            this.BaseAdd(property);
        }

        public IEnumerable GetProperties() 
        {
            List<ServerPropertyElement> properties = new List<ServerPropertyElement>();
            foreach (string key in BaseGetAllKeys())
            {
                properties.Add(Get(key));
            }
            return properties;
        }


        protected override string ElementName
        {
            get
            {
                return "ServerProperty";
            }
        }

        protected override ConfigurationElement CreateNewElement()
        {
            return new ServerPropertyElement();
        }

        protected override object GetElementKey(ConfigurationElement element)
        {
            return ((ServerPropertyElement)element).Key;
        }

        public override ConfigurationElementCollectionType CollectionType
        {
            get
            {
                return ConfigurationElementCollectionType.BasicMap;
            }
        }

    }
}
